package adminServlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import adminejb.AircraftBeanLocal;
import adminejb.AirlineBeanLocal;
import adminejb.AirportBeanLocal;
import adminejb.FlightBeanLocal;
import entities.Aircraft;
import entities.Airline;
import entities.Airport;
import entities.Flight;

/**
 * Servlet implementation class getParamsToCreate
 */
@WebServlet("/getParamsToCreate")
public class getParamsToCreate extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public getParamsToCreate() {
        super();
        // TODO Auto-generated constructor stub
    }
        
    @EJB
    AirlineBeanLocal airlineBean;
    
    @EJB
    AirportBeanLocal airportBean;
    
    @EJB
    AircraftBeanLocal aircraftBean;
    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	    	
    	ArrayList<Airline> airlineList = airlineBean.getAllAirlines();
    	ArrayList<Aircraft> aircraftList = aircraftBean.getAllAircrafts();
    	ArrayList<Airport> airportList = airportBean.getAllAirports();
    	    	
    	request.setAttribute("airlineList", airlineList);    	
    	request.setAttribute("aircraftList", aircraftList);    	
    	request.setAttribute("airportList", airportList);    	
    	
    	getServletContext().getRequestDispatcher("/admin/CreateFlight.jsp").forward(request, response);
    	
    }
    
    
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);	
	}

}
